package com.mj;

import com.mj.dao.BookDao;
import com.mj.entity.Book;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.Date;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"classpath:applicationContext.xml"})//单元测试
public class BookDemo {
    @Autowired
    protected BookDao bookDao;
    @Test
    public void ins(){
        /*Book book = new Book();
        book.setName("百年孤独");
        book.setPrice(300);
        book.setDate(new Date());
        bookDao.insert(book);*/
        bookDao.add("傲慢与偏见",200,new Date());
    }
    @Test
    public void de(){
        bookDao.deleteById(13);
    }
}
